package com.xiyu.service.controller.admin.infra.devops;
import com.xiyu.service.vo.infra.devops.project.ProjectListQueryOutput;
import com.xiyu.service.vo.infra.devops.project.ProjectSingleGetOutput;
import com.xiyu.service.vo.infra.devops.project.ProjectUpdateInput;
import com.xiyu.service.vo.infra.devops.project.ProjectCreateInput;
import com.xiyu.service.vo.infra.devops.project.ProjectPageQueryOutput;
import com.xiyu.service.vo.infra.devops.project.ProjectPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.infra.devops.ProjectService;
import com.xiyu.service.vo.infra.devops.project.*;

@Tag(name = "项目管理")
@RestController
@RequestMapping("/infra/devops/project")
@Validated
public class ProjectController {

    @Resource
    private ProjectService projectService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询项目")
    public CommonResult<PageResult<ProjectPageQueryOutput>> pageQuery(@Valid ProjectPageQueryInput inputVO) {
        return success(projectService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增项目")
    public CommonResult<Long> create(@Valid @RequestBody ProjectCreateInput inputVO) {
        return success(projectService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新项目")
    public CommonResult<Boolean> update(@Valid @RequestBody ProjectUpdateInput inputVO) {
        return success(projectService.update(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除项目")
    @Parameter(name = "id", description = "项目管理主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(projectService.deleted(id));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个项目")
    @Parameter(name = "id", description = "项目管理主键ID", example = "")
    public CommonResult<ProjectSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(projectService.singleGet(id));
    }

    @GetMapping("/list-query")
    @Operation(summary = "查询项目")
    public CommonResult<List<ProjectListQueryOutput>> listQuery() {
        return success(projectService.listQuery());
    }

}
